from appium import webdriver
import os
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class Base():
    def __init__(self):
        os.system('adb root')
        cap={
            "platformName": "Android",
            "appium:deviceName": "emulator-5554",
            "appium:noReset": True,
            "appium:appPackage": "com.xiachufang",
            "appium:appActivity": "com.xiachufang.activity.home.HomeActivity"
        }
        self.driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
        #隐世导航
        self.driver.implicitly_wait(20)
    #
    def find_ele(self,loc):
        ele=self.driver.find_element(*loc)
        return ele
    def find_wait_ele(self,loc):
        ele=WebDriverWait(self.driver,10).until(EC.element_to_be_clickable(loc))
        return ele
    def huadong(self,a,b,c,d):
        self.driver.swipe(a,b,c,d,100)

    def jieping(self,a):
        self.driver.save_screenshot(a)

    def qingqiao(self,a,b):
        self.driver.tap([(a,b)],100)

    def anjian(self):
        self.driver.press_keycode(3)

    def tuichu(self):
        self.driver.quit()














